# from selenium import webdriver
# from selenium.webdriver.support.ui import Select
#
# import time
from tinyshop_ui.common.input import common_input
from tinyshop_ui.common.login import common_login
from tinyshop_ui.common.iframe import common_iframe
from tinyshop_ui.common.findmodule import common_module
from tinyshop_ui.common.add import common_add
from tinyshop_ui.common.select import common_select
from tinyshop_ui.common.button import common_button
from tinyshop_ui.common.img import common_img
from tinyshop_ui.common.td import common_td


class tes_te:
    def allact(self,parm1,parm2,ls,expect):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_add(webd)
        common_input(webd).text(webd,ls)
        common_select().many_select(webd)
        common_iframe(webd,ls[-1])
        exp = common_td().res(webd,expect)
        webd.close()
        return exp
    def classmag(self,parm1,parm2,ls,expect):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_add(webd)
        common_input(webd).text(webd,ls)
        common_select().many_select(webd)
        exp = common_td().res(webd,expect)
        webd.close()
        return exp
    def admag(self,parm1,parm2,ls,expect):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_add(webd)
        common_input(webd).text(webd,ls)
        common_input(webd).checkbox()
        # common_button(webd)
        # common_img(webd)
        common_input(webd).submit()
        exp = common_td().res(webd,expect)
        webd.close()
        return exp
    def leadermsg(self,parm1,parm2,ls,expect):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_add(webd)
        common_input(webd).text(webd,ls)
        common_input(webd).submit()
        exp = common_td().res(webd,expect)
        webd.close()
        return exp
# ls = ['购物天堂','新闻','17']
# tes_te().classmag('内容管理','分类管理',ls)
#     def __init__(self):
#         self.driver = webdriver.Firefox()
#         self.driver.maximize_window()
#         self.driver.implicitly_wait(3)
#         self.driver.get('http://192.168.0.235/TinyShop_v2.4/index.php?con=goods&act=goods_type_list')
#
#         lw = self.driver.find_elements_by_tag_name('input')
#         na = ['admin','123456','aaaa']
#         for i in range(len(lw)):
#             if lw[i].get_attribute('type') != 'submit':
#                 lw[i].clear()
#                 lw[i].send_keys(na[i])
#             else:
#                 lw[i].click()
#                 break
#
#         self.driver.find_element_by_link_text('内容管理').click()
#         nv = ['全部文章','全部帮助']
#         for i in nv:
#             time.sleep(1)
#             self.driver.find_element_by_link_text(i).click()
#             time.sleep(1)
#             self.driver.find_element_by_xpath('//*[@id="content"]/form/div[1]/a[3]').click()
#             time.sleep(1)
#             self.driver.find_element_by_tag_name('input').send_keys('skdfj')
#             Select(self.driver.find_element_by_id('category_id')).select_by_value('1')
#             self.driver.find_element_by_xpath('//*[@id="obj_form"]/form/dl[3]/dd/div/div[1]/span[1]/span').click()
#             self.driver.find_element_by_xpath('/html/body').send_keys('Python is good')
#             self.driver.find_element_by_xpath('//*[@id="obj_form"]/form/div/input[1]').click()
#         nb = ['分类管理','帮助分类管理']
#         for i in nb:
#             time.sleep(1)
#             self.driver.find_element_by_link_text(i).click()
#             time.sleep(1)
#             self.driver.find_element_by_link_text('添加').click()
#             time.sleep(1)
#             Select(self.driver.find_element_by_id('parent_id')).select_by_value('0')
#             ce = ['新闻','count','88']
#             re = self.driver.find_elements_by_tag_name('input')
#             for i in range(len(re)):
#                 if re[i].get_attribute('type') != 'submit':
#                     re[i].clear()
#                     re[i].send_keys(ce[i])
#                 else:
#                     re[i].click()
#                     break
#         time.sleep(1)
#         self.driver.find_element_by_link_text('广告管理').click()
#         time.sleep(1)
#         self.driver.find_element_by_link_text('添加').click()
#         self.driver.find_element_by_xpath('//*[@id="obj_form"]/dl[6]/dd/textarea').send_keys('python is pmgood')
#         Select(self.driver.find_element_by_id('ad_type')).select_by_value('3')
#         oa = self.driver.find_elements_by_tag_name('input')
#         print(oa)
#         print(len(oa))
#         yh = ['皇家马德里','300','300','2017-06-15 11:27','2019-06-15 11:27','皇马是冠军','没有','#FF0000']
#         for i in range(len(oa)):
#             try:
#                 if oa[i].get_attribute('type') == 'text':
#                     oa[i].clear()
#                     oa[i].send_keys(yh[i])
#                 elif oa[i].get_attribute('type') == 'checkbox':
#                     oa[i].click()
#                 elif oa[i].get_attribute('type') == 'submit':
#                     oa[i].click()
#                 else:
#                     self.driver.find_element_by_xpath('//*[@id="content"]/h1').click()
#             except Exception as e:
#                 print(e)
#
#         time.sleep(2)
#         self.driver.close()
#
# if __name__ == '__main__':
#     tes_te()
